package com.fyzk.utils;

import com.fyzk.activity.user.coupon.CouponInfo;
import com.fyzk.bean.CouponListBean;

import java.text.SimpleDateFormat;
import java.util.Comparator;

/**
 * Created by fanxs11 on 16/5/31.
 */
public class ComparatorValues implements Comparator<CouponListBean.CouponsBean> {

    @Override
    public int compare(CouponListBean.CouponsBean couponInfo1, CouponListBean.CouponsBean couponInfo2) {

        int disamt1 = couponInfo1.getDisamt();
        int disamt2 = couponInfo2.getDisamt();
//        2016-05-31 00:00:00
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        long time1 = 0;
        long time2 = 0;
        try {
            time1 = sdf.parse(couponInfo1.getEndDate()).getTime();
            time2 = sdf.parse(couponInfo2.getEndDate()).getTime();
        } catch (Exception e) {

        }

        if (disamt1 < disamt2) {
            return -1;
        } else if (disamt1 == disamt2){
            if (time1 < time2) {
                return -1;
            } else {
                return 1;
            }
        } else {
            return 1;
        }

    }
}
